import Vue from 'vue'
import Router from 'vue-router'
import Home from './views/Home.vue'
import HotShow from './components/HotShow.vue'
import WillShow from './components/WillShow.vue'

const originalPush = Router.prototype.push;
Router.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err);
};

Vue.use(Router)

export default new Router({
	routes: [
		{
			path: '/',
			redirect: '/home'
		},
		{
			path: '/home',
			component: Home,
			children: [{
					path: 'hotshow',
					alias: '',
					component: HotShow
				},
				{
					path: 'willshow',
					component: WillShow
				}
			]
		},
		{
			path: '/cinema',
			name: 'cinema',
			component: () => import( /* webpackChunkName: "cinema" */ './views/Cinema.vue')
		},
		{
			path: '/me',
			name: 'me',
			component: () => import( /* webpackChunkName: "me" */ './views/Me.vue'),
			meta:{
				requestAuth: true
			}
		},
		{
			path: '/movie/:id',
			name: 'movie',
			component: () => import( /* webpackChunkName: "movie" */ './views/Movie.vue')
		},
		{
			path: '/login',
			name: 'login',
			component: () => import( /* webpackChunkName: "login" */ './views/Login.vue')
		},
		{
			path: '/search',
			name: 'search',
			component: () => import( /* webpackChunkName: "search" */ './views/Search.vue')
		}
	]
})
